package action;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

import pageModel.Json;
import pageModel.SaleReturn;
import service.SaleReturnServiceI;

import com.opensymphony.xwork2.ModelDriven;

@Namespace("/")
@Action(value="saleReturnAction")
public class SaleReturnAction extends BaseAction implements ModelDriven<SaleReturn>{
SaleReturn saleReturn = new SaleReturn();
private SaleReturnServiceI saleReturnService;

	public SaleReturnServiceI getSaleReturnService() {
	return saleReturnService;
}
@Autowired
public void setSaleReturnService(SaleReturnServiceI saleReturnService) {
	this.saleReturnService = saleReturnService;
}
	@Override
	public SaleReturn getModel() {
		return saleReturn;
	}
public void save(){
	Json j=new Json();	
	try{
	    saleReturnService.save(saleReturn);
	    j.setSuccess(true);
	    j.setMsg("退货成功!");
	}catch(Exception e){
		j.setMsg("退货失败!");
	}
	super.writeJson(j);
}
}
